package org.example.tialsproject.mapper;

import org.apache.ibatis.annotations.*;
import org.example.tialsproject.pojo.Emp;
import org.example.tialsproject.pojo.User;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    /*
     查询数据总记录数
    @Select("select count(*) from emp")
    public Long count();
    */
    /*
    分页查询
    @Select("select * from emp limit #{start},#{pageSize}")
    public List<Emp> fetchEmp(int start, int pageSize);
    */
    //  @Select("select * from emp")
    public List<Emp> fetchEmp(String name, Short gender, LocalDate begin, LocalDate end);

    /*删除员工方法*/
    @Delete("delete from emp where id in (${ids})")
    public void deleteEmp(String ids);

    /*添加员工方法*/
    @Insert(" insert into emp (username,name,gender,image,job,entrydate,dept_id,create_time,update_time) values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    public void addEmp(Emp emp);

    /*根据ID查询员工的方法*/
    @Select("select * from emp where id=#{id}")
    public Emp fetchEmpById(int id);

    /*修改员工的方法*/
    //@Update("update emp set username=#{username},name=#{name},gender=#{gender},image=#{image},job=#{job},entrydate=#{entrydate},dept_id={deptId},update_time=#{updateTime} where id=#{id}")
    public void updateEmp(Emp emp);

    /*登录的方法*/
    @Select("select * from emp where username=#{username} and password=#{password}")
    public Emp userLogin(User user);
}
